package com.example.JavaConcurrent.Project2_CountDownLatchAndCyclicBarrier.CyclicBarrierBegin_8;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

public class MyService {
    //3等2
    CyclicBarrier cbRef = new CyclicBarrier(3, new Runnable() {
        @Override
        public void run() {
            System.out.println("都到了");
        }
    });


    public void testMethod(){
        try {
            System.out.println(Thread.currentThread().getName() + " begin1-Time="+System.currentTimeMillis());
            cbRef.await();
            System.out.println(Thread.currentThread().getName() + " Begin1-Time="+System.currentTimeMillis());
        } catch (InterruptedException | BrokenBarrierException e) {
            e.printStackTrace();
        }
    }


}
